<!--
*
* Copyright 2015 HISP Tanzania
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* @since 2015
* @author Joseph Chingalo profschingalo@gmail.com>
*
*
-->
<ion-header>

  <ion-navbar [color]="(colorSettings$ |async).colorAttributes.main">
    <ion-title>
      <span [translate]="'Data entry'"></span>
    </ion-title>
  </ion-navbar>

</ion-header>


<ion-content>
  <ion-grid>
    <ion-row>
      <ion-col class="animated fadeIn">
        <div class="item-card" color="font-color" padding-top padding-bottom ion-button clear full text-center
          text-capitalize (tap)="openOrganisationUnitTree()">
          <img class="side-menu-icon" [src]="icons.orgUnit" />&nbsp;&nbsp;
          <span *ngIf="!selectedOrgUnit || !selectedOrgUnit.name" [translate]="organisationUnitLabel"></span>
          <span *ngIf="selectedOrgUnit && selectedOrgUnit.name" [translate]="organisationUnitLabel"></span>
        </div>

        <div class="item-card" color="font-color" padding-top padding-bottom ion-button clear full text-center
          text-capitalize (tap)="openEntryFormList()">
          <img class="side-menu-icon" [src]="icons.dataSet" />&nbsp;&nbsp;
          <span *ngIf="!selectedDataSet || !selectedDataSet.name" [translate]="dataSetLabel"></span>
          <span *ngIf="selectedDataSet && selectedDataSet.name">{{ selectedDataSet.name }}</span>
        </div>

        <div class="item-card" color="font-color" padding-top padding-bottom ion-button clear full text-center
          text-capitalize (tap)="openPeriodList()">
          <img class="side-menu-icon" [src]="icons.period" />&nbsp;&nbsp;
          <span *ngIf="!selectedPeriod || !selectedPeriod.name" [translate]="periodLabel"></span>
          <span *ngIf="selectedPeriod && selectedPeriod.name "> {{ selectedPeriod.name }}</span>
        </div>

        <div *ngIf="selectedPeriod && selectedPeriod.iso && dataSetCategoryCombo && dataSetCategoryCombo.id ">
          <div *ngIf="isDataSetDimensionApplicable">
            <div *ngFor="let category of dataSetCategoryCombo.categories;let categoryIndex = index">
              <div (tap)="openDataDimensionSelection(category)" class="item-card-category animated fadeIn" color="font-color"
                full text-center text-wrap>
                <div style="padding-bottom: 5px;">
                  <b>{{ category.name }}</b>
                </div>
                <div *ngIf="selectedDataDimension[categoryIndex]">{{ selectedDataDimension[categoryIndex].name }}</div>
                <div *ngIf="!selectedDataDimension[categoryIndex]">
                  <span [translate]="'Touch to select option'"></span>
                </div>
              </div>
            </div>
          </div>
          <div class="item-card animated fadeIn" *ngIf="!isDataSetDimensionApplicable">
            <warning [warningMessage]="isDataSetDimensionApplicableCategoriesMessage"></warning>
          </div>
        </div>
        <div *ngIf="isFormReady" class="item-card animated fadeIn" padding-top padding-bottom full (tap)="openDataEntryForm()">
          <div>
            <b>
              <span [translate]="'Organisation unit'"></span>
            </b> : {{ organisationUnitLabel }}
            <br>
            <b>
              <span [translate]="'Form'"></span>
            </b> : {{ dataSetLabel }}
            <br>
            <b>
              <span [translate]="'Period'"></span>
            </b> : {{ periodLabel}}
          </div>
          <div class="item-card" color="font-color" ion-button clear full text-center text-capitalize>
            <img class="side-menu-icon" [src]="icons.goToDataEntryForm" />&nbsp;&nbsp;
            <span [translate]="'Enter data'"></span>
          </div>
        </div>
      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content>
